package com.zh.login.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description:
 * @ClassName TestClassCaseMap
 * @date: 2021.04.09 11:15
 * @Author: zhanghang
 */
public class TestClassCaseMap {

    public static void main(String[] args) {
        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        list1.add("1");
        list1.add("2");
        list2.add("2");
        list2.add("4");
        // 判断两个集合是否有交集
        boolean disjoint = Collections.disjoint(list1, list2);
        System.out.println(disjoint);

        List<TestClass> list = new ArrayList<>();
        list.add(new TestClass(1L,"123","zhangsan"));
        list.add(new TestClass(2L,"123","lisi"));
        list.add(new TestClass(3L,"456","wangwu"));
        list.add(new TestClass(4L,"456","zhaoliu"));
        list.add(new TestClass(5L,"123","xiaohong"));
        list.add(new TestClass(6L,"789","haha"));
        list.add(new TestClass(7L,"123","kaka"));



        Map<String, List<Long>> map = list.stream().collect(Collectors.groupingBy(TestClass::getInfoId,
                Collectors.mapping(TestClass::getId,Collectors.toList())));
        System.out.println(map.size());
        System.out.println(map);
    }
}
